//
//  DemoController.swift
//  ImitateWeiBo
//
//  Created by study on 2017/3/3.
//  Copyright © 2017年 WY. All rights reserved.
//

import UIKit

class DemoController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 设置标题
        title = "第 \(navigationController?.childViewControllers.count ?? 0) 个"
        
        
//        let button = UIButton(type: UIButtonType.system) as UIButton
//        
//        button.frame = CGRect(x: 100, y: 100, width: 50, height: 50)
//        button.backgroundColor = UIColor.red
//        button.addTarget(self, action: #selector(ClickBtnChangeLocal), for: .touchUpInside)
//        self.view.addSubview(button)
    }
    
    // MARK: - 监听方法
    /// 继续 PUSH 一个新的控制器
    @objc fileprivate func showNext() {
        
        let vc = DemoController()
        
        navigationController?.pushViewController(vc, animated: true)
    }
    
    func ClickBtnChangeLocal(){
        print("点击了按钮")
        
        
    }
    
    
//    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
////        if UIDevice.current.userInterfaceIdiom == .phone {
//            return .landscapeLeft
////        } else {
////            return .all
////        }
//    }
}

extension DemoController {
    
    /// 重写父类方法
    override func setupUI() {
        
        super.setupUI()
        
        // 设置右侧的控制器
        // navigationItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", style: .plain, target: self, action: #selector(showNext))
        let btn: UIButton = UIButton.cz_textButton("下一个", fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        btn.addTarget(self, action: #selector(showNext), for: .touchUpInside)
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
    }


}
